package com.css.fxfzdzzh.util;

import com.css.fxfzdzzh.base.response.ResponseCode;
import com.css.fxfzdzzh.base.response.RestResponse;

/**
 * @author Dbj
 * @date 2022年09月06日  10:51
 */
public class ResponseCreator {

    public static RestResponse createSuccessResponse(Object obj,String message){
        RestResponse restResponse = createSuccessResponse(obj);
        restResponse.setMessage(message);
        return restResponse;
    }

    public static RestResponse createSuccessResponse(Object obj){
        if (PlatformObjectUtils.isNotEmpty(obj)) {
            return RestResponse.succeed(obj);
        }
        return RestResponse.succeed();
    }
    public static RestResponse createFailResponse(Object obj){
        if(PlatformObjectUtils.isNotEmpty(obj)){
            return RestResponse.fail(ResponseCode.INTERNAL_SERVER,(String)obj);
        }
        return RestResponse.fail(ResponseCode.INTERNAL_SERVER,"操作失败");
    }
}
